//
//  LGSportOrderViewController.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/11/6.
//  运动评估订单

#import "LGSportOrderViewController.h"
#import "LGSportOrderAppointController.h"
#import "LGSportOrderTableController.h"
@interface LGSportOrderViewController ()
/**   */
@property (nonatomic , strong)LGNavigationView *navigationView;
/**   */
@property (nonatomic , strong)CAGradientLayer *gradientLayer;
/**   */
@property (nonatomic , strong)LGSportOrderAppointController *appointVC;
/**   */
@property (nonatomic , strong)LGSportOrderTableController *orderVC;
/**   */
@property (nonatomic , strong)NSMutableArray *controllerArray;
/**   */
@property (nonatomic , strong)NSArray *titleArray;

@end

@implementation LGSportOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self commonInit];
}

-(void)backButtonAction{
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark
#pragma mark ====> WMPageControllerDelegate
- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController {
    return self.titleArray.count;
}

- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index {
    return self.titleArray[index];
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    return self.controllerArray[index];
}

- (CGFloat)menuView:(WMMenuView *)menu widthForItemAtIndex:(NSInteger)index {
    return Screen_W/5.0;
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView {
    return CGRectMake(0, topBarHeight, Screen_W, viewPix(44));
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView {
    return CGRectMake(0, topBarHeight+viewPix(44), Screen_W, Screen_H-topBarHeight-viewPix(44));
}

- (void)pageController:(WMPageController *)pageController willEnterViewController:(__kindof UIViewController *)viewController withInfo:(NSDictionary *)info{
    LGBaseViewController *controller = (LGBaseViewController *)viewController;
    [controller requestData];
    NSLog(@">>>>>willEnterView>>>%@",viewController.title);
}

- (void)pageController:(WMPageController *)pageController didEnterViewController:(__kindof UIViewController *)viewController withInfo:(NSDictionary *)info{
    NSLog(@">>>>>didEnterView>>>%@",viewController.title);
}

-(void)commonInit{
    self.fd_prefersNavigationBarHidden = YES;
    self.view.backgroundColor = [UIColor colorWithString:@"#F2F3F5"];
    [self.view addSubview:self.navigationView];
    [self.view.layer addSublayer:self.gradientLayer];
    self.titleArray = @[@"预约记录",@"购买订单"];
    [self addChildViewController:self.appointVC];
    [self addChildViewController:self.orderVC];
    [self.controllerArray addObject:self.appointVC];
    [self.controllerArray addObject:self.orderVC];
    
    self.titleColorNormal = [UIColor colorWithString:@"#666666"];
    self.titleColorSelected = [UIColor colorWithString:kThemeColor];
    self.progressColor = [UIColor colorWithString:kThemeColor];
    self.menuViewStyle=WMMenuViewStyleLine;
    self.titleFontName = @"STHeitiTC-Medium";
    self.titleSizeSelected = 16;
    self.titleSizeNormal = 14;
    self.progressWidth = viewPix(13);
    self.progressHeight = 4;
    self.progressViewBottomSpace = 0;
    self.progressViewCornerRadius = 2;
    [self reloadData];
    self.scrollView.backgroundColor = [UIColor clearColor];
}

-(NSMutableArray *)controllerArray{
    if(!_controllerArray){
        _controllerArray = [NSMutableArray array];
    }
    return _controllerArray;
}

-(CAGradientLayer *)gradientLayer{
    if(!_gradientLayer){
        _gradientLayer = [CAGradientLayer layer];
        _gradientLayer.frame = CGRectMake(0,topBarHeight,Screen_W,viewPix(167));
        _gradientLayer.startPoint = CGPointMake(0.5, 0);
        _gradientLayer.endPoint = CGPointMake(0.5, 1.03);
        _gradientLayer.colors = @[(__bridge id)[UIColor colorWithString:@"#E5F3FF"].CGColor, (__bridge id)[UIColor colorWithString:@"#F3F9FE"].CGColor, (__bridge id)[UIColor colorWithString:@"#FEFEFF" alpha:0].CGColor];
        _gradientLayer.locations = @[@(0), @(0.4f), @(1.0f)];
    }
    return _gradientLayer;
}

-(LGNavigationView *)navigationView{
    if(!_navigationView){
        _navigationView = [[LGNavigationView alloc]initWithFrame:CGRectMake(0, 0, Screen_W, topBarHeight)];
        _navigationView.backgroundColor = [UIColor colorWithString:@"#E5F3FF"];
        _navigationView.title = @"运动评估订单";
        [_navigationView.backBtn addTarget:self action:@selector(backButtonAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _navigationView;
}

-(LGSportOrderAppointController *)appointVC{
    if(!_appointVC){
        _appointVC = [[LGSportOrderAppointController alloc] init];
    }
    return _appointVC;
}

-(LGSportOrderTableController *)orderVC{
    if(!_orderVC){
        _orderVC = [[LGSportOrderTableController alloc] init];
    }
    return _orderVC;
}


@end
